/*
 * =====================================================================================
 *
 *       Filename:  cl_active_object.hxx
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  12/24/2010 02:28:18 AM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Ken Chen (Ken), chen_kenz@emc.com
 *        Company:  EMC
 *
 * =====================================================================================
 */

#ifndef _CL_ACTIVE_OBJECT_HXX_
#define _CL_ACTIVE_OBJECT_HXX_

#include <memory>
#include <functional>
#include "cl_thread.hxx" 
#include "cl_pc_queue.hxx"

namespace neo
{
class CLActiveObject
{
public:
	typedef std::function<void()> Callback;
  CLActiveObject();
  ~CLActiveObject();
  void send(Callback func);

private:
  void run(void);
	void setDone(void);

private:
  CLActiveObject(const CLActiveObject&);
  CLActiveObject& operator=(const CLActiveObject&);

private:
  typedef CLProducerConsumerQueue<Callback> MessageQueue;
  MessageQueue m_msgQueue;
  std::unique_ptr<CLThread> m_thr;
  bool m_done;
};
} // neo

#endif //_CL_ACTIVE_OBJECT_HXX_

